package com.etone.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.etone.common.annotation.Log;
import com.etone.common.core.controller.BaseController;
import com.etone.common.core.domain.AjaxResult;
import com.etone.common.enums.BusinessType;
import com.etone.system.domain.SysDibiao;
import com.etone.system.service.ISysDibiaoService;
import com.etone.common.utils.poi.ExcelUtil;
import com.etone.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 *
 * @author etone
 * @date 2025-05-27
 */
@RestController
@RequestMapping("/system/dibiao")
public class SysDibiaoController extends BaseController
{
    @Autowired
    private ISysDibiaoService sysDibiaoService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:dibiao:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysDibiao sysDibiao)
    {
        startPage();
        List<SysDibiao> list = sysDibiaoService.selectSysDibiaoList(sysDibiao);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:dibiao:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysDibiao sysDibiao)
    {
        List<SysDibiao> list = sysDibiaoService.selectSysDibiaoList(sysDibiao);
        ExcelUtil<SysDibiao> util = new ExcelUtil<SysDibiao>(SysDibiao.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dibiao:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysDibiaoService.selectSysDibiaoById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:dibiao:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysDibiao sysDibiao)
    {
        return toAjax(sysDibiaoService.insertSysDibiao(sysDibiao));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:dibiao:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysDibiao sysDibiao)
    {
        return toAjax(sysDibiaoService.updateSysDibiao(sysDibiao));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:dibiao:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysDibiaoService.deleteSysDibiaoByIds(ids));
    }

    /**
     * App端获取集合
     * @return
     */
    @RequestMapping("/getApplist")
    public AjaxResult getApplist(){
        return AjaxResult.success(sysDibiaoService.getApplist());
    }

    /**
     * 获取空闲地表位置列表
     * @return
     */
    @RequestMapping("/getLieBiaoList")
    public AjaxResult getLieBiaoList(){
        return AjaxResult.success(sysDibiaoService.getLieBiaoList());
    }

    /**
     * 新增一个货架，绑定地标号
     */
    @RequestMapping("/addByHuojia")
    public AjaxResult addByHuojia(@RequestParam(value = "name") String name,@RequestParam(value = "type") String type,
                                     @RequestParam(value = "huojia") String huojia){
        return toAjax(sysDibiaoService.addByHuojia(name,type,huojia));
    }

    /**
     * 解出货架与地标关系
     * @param id
     * @return
     */
    @RequestMapping("/jiebangByHuojia")
    public AjaxResult jiebangByHuojia(@RequestParam(value = "id") Long id){
        return toAjax(sysDibiaoService.jiebangByHuojia(id));
    }

    /**
     * 根据id获取详情
     * @param id
     * @return
     */
    @RequestMapping("/getSysDibiaoById")
    public AjaxResult getSysDibiaoById(@RequestParam(value = "id") Long id)
    {
        return success(sysDibiaoService.selectSysDibiaoById(id));
    }
}
